<%@ page language="java" pageEncoding="utf8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"
	dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<c:url value="/css/shopadmin.css"/>"
			type="text/css" />
	</head>
	<body style="">
		<div id="headBar" class="head_content"></div>
		<div id="main" class="main_content">
			<form action="sys_admin_save.do" method="post" class="tableform"
				id="adminUser_form">
				<input type="hidden" value="${adminUser.adminId }" 		name="adminUser.adminId" />
				<input type="hidden" value="${adminUser.adminNo }" 		name="adminUser.adminNo" />
				
					<div class="division">
						<table width="100%" cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<th>
										用户名：
									</th>
									<td>
										<input type="text" value="${adminUser.username }"
											style="width: 120px;" name="adminUser.username"
											class="x-input " />
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<c:if test="${not empty adminUser.adminId}">
						<div class="division">
							<table width="100%" cellspacing="0" cellpadding="0" border="0">
								<tbody>
									<tr>
										<th>
											&nbsp;
										</th>
										<td>
											<input name="adminUser.changepwd" value="true" id="x-ipt-changepwd"
												onclick="$('#x-div-changepwd').css('display',this.checked?'':'none')"
												type="checkbox" />
												<label  >
													同时修改密码
												</label>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</c:if>
					<c:if test="${  empty adminUser.adminId}">
						<input name="adminUser.changepwd" value="true" type="hidden" /> 
					</c:if>
				<div id="x-div-changepwd" class="division" >
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									密码：
								</th>
								<td>
									<input type="password" id="x-input-admin-pwd"
										value="${adminUser.userpass}" style="width: 120px;"
										name="adminUser.userpass" />
								</td>
							</tr>
							<tr>
								<th>
									确认密码：
								</th>
								<td>
									<input type="password" style="width: 120px;"
										value="${adminUser.userpass}" name="adminUser.userpassComfirm" />
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									超级管理员 ：
								</th>
								<td>
									<select id="adminUser_adminSuper" name="adminUser.adminSuper">
										<option value="1">
											是
										</option>
										<option value="0">
											否
										</option>
									</select>
								</td>
							</tr>
							<tr id="x-opt-roles">
								<th>
									权限角色：
								</th>
								<td>
									<c:forEach var="role" items="${systemAdminRoles}"
										varStatus="index">
										<div>
											<input type="hidden" value="${role.arId}"
												name="systemAdminRoles[${index.index}].arId" />
											<input type="checkbox" value="${role.roleId}"
												<c:if test="${not empty  role.arId}">checked="checked"</c:if>
												name="systemAdminRoles[${index.index}].roleId" />
											<label style="margin-right: 50px;">
												${role.roleName}
											</label>
										</div>
									</c:forEach>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									是否启用：
								</th>
								<td>
									<select id="adminUser_status" name="adminUser.status">
										<option value="true">
											是
										</option>
										<option value="false">
											否
										</option>
									</select>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									姓名：
								</th>
								<td>
									<input type="text" maxlength="50" value="${adminUser.name }"
										name="adminUser.name" />
								</td>
							</tr> 
							<tr>
								<th>
									部门：
								</th>
								<td>
									<input type="text" maxlength="50"
										value="${adminUser.department }" name="adminUser.department" />
								</td>
							</tr> 
						</tbody>
					</table>
				</div>
				<div class="table-action">
					<button class="btn" type="submit">
						<span><span>保存</span> </span>
					</button>
				</div>
			</form>
		</div>
		<div id="footBar" class="foot_content"></div>



		<script type="text/javascript"
			src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/jquery.validate.js'/>"></script>
		<script type="text/javascript">
	<c:if test="${not empty adminUser.adminId}">
 	$('#adminUser_status').attr('value','${adminUser.status}');
 	$('#adminUser_adminSuper').attr('value','${adminUser.adminSuper}');
 	$('#x-div-changepwd').css('display','none');
 </c:if>

	$(document).ready(function() {
		var validator = $("#adminUser_form").validate( {
			errorElement : "div",
			errorClass : "x-vali-error",
			onfocusout : false,
			rules : {
				'adminUser.username' : "required",
				'adminUser.name' : "required",
				'adminUser.userpass' : "required",
				'adminUser.userpassComfirm' : "required",
				
				'adminUser.department' : {
					required : true 
				}
			},
			messages : {
				'adminUser.username' : "必填字段", 
				'adminUser.name' : "必填字段", 
				'adminUser.userpass' : "必填字段", 
				'adminUser.userpassComfirm' : "必填字段", 
				
				'adminUser.department' : {
					required : "必填字段" 
				}
			},
			errorPlacement : function(error, element) {
				element.removeClass('x-vali-error');
				error.appendTo(element.parent());

			},

			success : function(div) {
				$(div).remove();
			}
		});
	});
</script>
	</body>
</html>